package com.example.appointment.adapter;

import android.content.Context;
import android.os.Handler;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.example.appointment.R;
import com.example.appointment.meta.CitiesBean;

import java.util.ArrayList;

/**
 * 意见反馈的适配器
 * Created by hehe on 2016/7/5.
 */
public class FeedBackPhotoAdapter extends RecyclerView.Adapter<FeedBackPhotoAdapter.MyViewHolder> {
    private Context context;
    private ArrayList<String> arrayList;
    private Handler mHander;

    public void removeitem(CitiesBean item) {
        int index = arrayList.indexOf(item);
        arrayList.remove(item);
        notifyItemRemoved(index);
    }

    public void clearall() {
        arrayList.clear();
        notifyDataSetChanged();
    }

    public void additem(String item) {

        this.arrayList.add(item);
        int index = arrayList.indexOf(item);
        notifyItemInserted(index);
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        MyViewHolder holder = new MyViewHolder(LayoutInflater.from(
                context).inflate(R.layout.item_feedbackphoto, parent,
                false));
        return holder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        final String itemvo = arrayList.get(position);

    }

    @Override
    public int getItemCount() {
        return arrayList.size();
    }

    public ArrayList<String> getArrayList() {
        return arrayList;
    }

    public void setArrayList(ArrayList<String> arrayList) {
        this.arrayList = arrayList;
    }

    public FeedBackPhotoAdapter(Context context, Handler mHander) {
        this.context = context;
        this.mHander = mHander;
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        ImageView choosedimg;//选择的照片
        ImageView deleteimg;//选择的照片

        public MyViewHolder(View itemView) {
            super(itemView);
            deleteimg = (ImageView) itemView.findViewById(R.id.item_feedbackphoto_delete);
            choosedimg = (ImageView) itemView.findViewById(R.id.item_feedbackphoto_img);

        }
    }

}
